#ifndef __BIND_JSON_PROTOCOL_H__
#define __BIND_JSON_PROTOCOL_H__
#include <cJSON.h>
#include <ra_device_state.h>
#include <ra_cloud.h>

#define APPTID_LENGTH_MAX 64

#define ACTION_CODE_SUCCESS					200
#define ACTION_CODE_IDLE					201
#define ACTION_CODE_ERROR_PARSE_ERROR		2000102
#define ACTION_CODE_ERROR_ACTION_UNKNOWN	2000103
#define ACTION_CODE_ERROR_UART_TIMEOUT		2000105
#define ACTION_CODE_ERROR_FORMAT			2000106
#define ACTION_CODE_ERROR_DEVTID			2000107
#define ACTION_CODE_ERROR_CTRLKEY			2000109
#define ACTION_CODE_ERROR_EXECUTION 		2000114
#define ACTION_CODE_ERROR_BIN_TYPE			2000115
#define ACTION_CODE_ERROR_UPDATE_STARTED 	2000116
#define ACTION_CODE_ERROR_FRAME_INVALID 	2000117
#define ACTION_CODE_ERROR_INTERNAL_ERROR 	2000118
#define ACTION_CODE_ERROR_USER_NOT_EXIST 	2000119

#define JSON_PROTOCOL_FIELD_MSGID		"msgId"
#define JSON_PROTOCOL_FIELD_ACTION		"action"
#define JSON_PROTOCOL_FIELD_PARAMS		"params"
#define JSON_PROTOCOL_FIELD_CODE		"code"
#define JSON_PROTOCOL_FIELD_DESC		"desc"


#define JSON_PROTOCOL_FIELD_DEVTID		"devTid"
#define JSON_PROTOCOL_FIELD_APPTID		"appTid"
#define JSON_PROTOCOL_FIELD_CMDID		"cmdId"
#define JSON_PROTOCOL_FIELD_DATA		"data"

#define JSON_ACTION_RESP_LENGTH_MAX 20
#define RESP "Resp"
#define JSON_PROTOCOL_ACTION_RESP_APPSEND "appSendResp"
#define ACTION_RESP_UNKNOWN_NAME "errorResp"

#define JSON_PROTOCOL_ACTION_DEVSEND	"devSend"



#define MSG_JSON_LENGTH_MAX 512

char *get_code_desc(uint32_t code);
void action_resp_handle(cJSON *msgid, cJSON *action, cJSON *params, uint32_t code);

void bind_dev_sync(cJSON *whole, void *arg);
void bind_get_timer_list_resp(cJSON *whole, void *arg);

typedef uint32_t(ma_task_cb_func) (cJSON *params);
void ma_task_callback_regist(ma_task_cb_func *func);//用户业务回调注册函数
FUN_ATTRIBUTE void  ma_devsend_to_report(cJSON *data);

#endif